package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.OrderPaymentRecord;
import com.ktgj.service.service.IOrderPaymentRecordService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 订单线上支付信息Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/record")
public class OrderPaymentRecordController extends BaseController
{
    @Autowired
    private IOrderPaymentRecordService orderPaymentRecordService;

    /**
     * 查询订单线上支付信息列表
     */
    @PreAuthorize(hasPermi = "service:record:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderPaymentRecord orderPaymentRecord)
    {
        startPage();
        List<OrderPaymentRecord> list = orderPaymentRecordService.selectOrderPaymentRecordList(orderPaymentRecord);
        return getDataTable(list);
    }

    /**
     * 导出订单线上支付信息列表
     */
    @PreAuthorize(hasPermi = "service:record:export")
    @Log(title = "订单线上支付信息 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderPaymentRecord orderPaymentRecord) throws IOException
    {
        List<OrderPaymentRecord> list = orderPaymentRecordService.selectOrderPaymentRecordList(orderPaymentRecord);
        ExcelUtil<OrderPaymentRecord> util = new ExcelUtil<OrderPaymentRecord>(OrderPaymentRecord.class);
        util.exportExcel(response, list, "订单线上支付信息 数据");
    }

    /**
     * 获取订单线上支付信息详细信息
     */
    @PreAuthorize(hasPermi = "service:record:query")
    @GetMapping(value = "/{paymentrecordsId}")
    public AjaxResult getInfo(@PathVariable("paymentrecordsId") Long paymentrecordsId)
    {
        return AjaxResult.success(orderPaymentRecordService.selectOrderPaymentRecordById(paymentrecordsId));
    }

    /**
     * 新增订单线上支付信息
     */
    @PreAuthorize(hasPermi = "service:record:add")
    @Log(title = "订单线上支付信息 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderPaymentRecord orderPaymentRecord)
    {
        return toAjax(orderPaymentRecordService.insertOrderPaymentRecord(orderPaymentRecord));
    }

    /**
     * 修改订单线上支付信息
     */
    @PreAuthorize(hasPermi = "service:record:edit")
    @Log(title = "订单线上支付信息 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderPaymentRecord orderPaymentRecord)
    {
        return toAjax(orderPaymentRecordService.updateOrderPaymentRecord(orderPaymentRecord));
    }

    /**
     * 删除订单线上支付信息
     */
    @PreAuthorize(hasPermi = "service:record:remove")
    @Log(title = "订单线上支付信息 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paymentrecordsIds}")
    public AjaxResult remove(@PathVariable Long[] paymentrecordsIds)
    {
        return toAjax(orderPaymentRecordService.deleteOrderPaymentRecordByIds(paymentrecordsIds));
    }
}
